<?php
// +----------------------------------------------------------------------
// | Author: derek <693472824@qq.com> <http://www.bloveambition.com/>
// +----------------------------------------------------------------------

namespace Api\Controller;
use Think\Model;
use Api\Logic\UserLogic;

/**
 * 投诉建议控制器
 * @author derek <693472824@qq.com>
 */
class FeedbackController extends BaseController {
    
    /**
     * 列表
     * @author derek <693472824@qq.com>
     */
    public function index(){
        
        $userID = $this->checkLogin('Feedback/index');
        
        $this->display();
    }
    
    /**
     * 保存用户反馈信息
     */
    public function ajax_save(){
        
        $userID = UserLogic::is_login();
        
        if(empty($userID)){
            $this->result['status'] = -201;
        }else{
        
            $feedback = D('Feedback');
            $content = I('content');
            
            if(!empty($content)){
                
                $data['content'] = $content;
                $data['user_id'] = $userID;
                $data['create_time'] = NOW_TIME;
                
                if($feedback->create($data)){
                    
                    $feedback->add();
                }
            }
            
            $this->result['status'] = 1;
        }
        
        $this->ajaxReturn($this->result);
    }
    
}
